/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * SettingsFrame.java
 *
 * Created on Jan 4, 2010, 6:59:52 PM
 */

package posturecorrectionsystem.gui;

import java.awt.FileDialog;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Properties;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JSpinner;
import javax.swing.WindowConstants;

/**
 *
 * @author ahmet
 */
public class SettingsManager extends javax.swing.JFrame {

    private String[] settingsKeys = {//"warnPostureDeterioration",
                                 "warnPosturePopup",
                                 "warnPostureSound",
                                 "warnPostureRestriction",
                                 //"warnWork",
                                 "warnWorkInterval",
                                 "warnWorkPopup",
                                 "warnWorkSound",
                                 "warnWorkRestriction",
                                 //"warnBreak",
                                 "warnBreakInterval",
                                 "warnBreakPopup",
                                 "warnBreakSound"};
    
    private String[] settingsDefaultValues = {//"true",  //"warnPostureDeterioration",
                                              "true",  //"warnPosturePopup",
                                              "false", //"warnPostureSound",
                                              "false", //"warnPostureRestriction",
                                              //"false", //"warnWork",
                                              "60",    //"warnWorkInterval",
                                              "false", //"warnWorkPopup",
                                              "false", //"warnWorkSound",
                                              "false", //"warnWorkRestriction",
                                              //"false", //"warnBreak",
                                              "15",    //"warnBreakInterval",
                                              "false", //"warnBreakPopup",
                                              "false"};//"warnBreakSound"};

    private Properties settings;

    private void setCheckBox(JCheckBox jcb, String value) {
        if(value.equals("true")) {
            jcb.setSelected(true);
        } else {
            jcb.setSelected(false);
        }
    }

    private void setComboBox(JComboBox jcb, String value) {
        for(int i=0; i<jcb.getModel().getSize(); i++){
            String indexValue = (String)jcb.getModel().getElementAt(i);
            if (indexValue.equals(value)){
                jcb.setSelectedIndex(i);
            }
        }
    }

    private void setSpinner(JSpinner js, String value) {
        js.setValue(Double.parseDouble(value)/60000);
    }

    private String getCheckBoxValue(JCheckBox jcb) {
        if (jcb.isSelected())
            return "true";
        else
            return "false";
    }

    private String getSpinnerValue(JSpinner js) {
        return ""+(int)(((Double)js.getValue())*60000);
    }

    private String getComboBoxValue(JComboBox jcb){
        return (String)jcb.getSelectedItem();
    }

    private void saveDefaultSettings(Properties settings){
        settings.setProperty("warnPosturePopup", "true");
        settings.setProperty("warnPostureSound", "false");
        settings.setProperty("warnPostureRestriction", "false");

        settings.setProperty("warnWorkPopup", "false");
        settings.setProperty("warnWorkSound", "false");
        settings.setProperty("warnWorkRestriction", "false");

        settings.setProperty("warnBreakPopup", "false");
        settings.setProperty("warnBreakSound", "false");

        settings.setProperty("warnWorkInterval", "60");
        settings.setProperty("warnBreakInterval", "15");
        
        try {
            settings.store(new FileOutputStream(settingsFilename), null);
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        } catch (IOException ex2) {
            ex2.printStackTrace();
        }
    }

    private void setComponents(Properties settings) {
         //setCheckBox(warnPostureDeterioration, properties.getProperty("warnPostureDeterioration"));
         setCheckBox(warnPosturePopup, settings.getProperty("warnPosturePopup"));
         setCheckBox(warnPostureSound, settings.getProperty("warnPostureSound"));
         setCheckBox(warnPostureRestriction, settings.getProperty("warnPostureRestriction"));

         //setCheckBox(warnWork, properties.getProperty("warnWork"));
         setCheckBox(warnWorkPopup, settings.getProperty("warnWorkPopup"));
         setCheckBox(warnWorkSound, settings.getProperty("warnWorkSound"));
         setCheckBox(warnWorkRestriction, settings.getProperty("warnWorkRestriction"));

         //setCheckBox(warnBreak, properties.getProperty("warnBreak"));
         setCheckBox(warnBreakPopup, settings.getProperty("warnBreakPopup"));
         setCheckBox(warnBreakSound, settings.getProperty("warnBreakSound"));

         //setComboBox(warnWorkInterval, settings.getProperty("warnWorkInterval"));
         //setComboBox(warnBreakInterval, settings.getProperty("warnBreakInterval"));
         setSpinner(warnWorkInterval, settings.getProperty("warnWorkInterval"));
         setSpinner(warnBreakInterval, settings.getProperty("warnBreakInterval"));
    }

    public void loadSettings(Properties settings) {
        try {
            settings.load(new FileInputStream(settingsFilename));
            System.out.println("File found");
        } catch (FileNotFoundException ex) {
            //no settings file found - prepare a default one
            ex.printStackTrace();
            //save default settings and load aggain
            saveDefaultSettings(settings);
            loadSettings(settings);
        } catch (IOException ex2) {
            ex2.printStackTrace();
        }
        //prepare components
        setComponents(settings);
    }

    private void saveSettings(Properties settings) {
        settings.setProperty("warnPosturePopup", getCheckBoxValue(warnPosturePopup));
        settings.setProperty("warnPostureSound", getCheckBoxValue(warnPostureSound));
        settings.setProperty("warnPostureRestriction", getCheckBoxValue(warnPostureRestriction));

        settings.setProperty("warnWorkPopup", getCheckBoxValue(warnWorkPopup));
        settings.setProperty("warnWorkSound", getCheckBoxValue(warnWorkSound));
        settings.setProperty("warnWorkRestriction", getCheckBoxValue(warnWorkRestriction));

        settings.setProperty("warnBreakPopup", getCheckBoxValue(warnBreakPopup));
        settings.setProperty("warnBreakSound", getCheckBoxValue(warnBreakSound));

        settings.setProperty("warnWorkInterval", getSpinnerValue(warnWorkInterval));
        settings.setProperty("warnBreakInterval", getSpinnerValue(warnBreakInterval));

        try {
            settings.store(new FileOutputStream(settingsFilename), null);
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        } catch (IOException ex2) {
            ex2.printStackTrace();
        }
    }

    private void importSettings() {
        FileDialog importDialog = new FileDialog(this, "Import settings...", FileDialog.LOAD);
        importDialog.setFilenameFilter(new FilenameFilter() {
            public boolean accept(File dir, String name) {
                return name.endsWith(settingsFileExtension);
            }
        });
        //importDialog.setFile("settings.properties");
        importDialog.setVisible(true);

        String importFilename = importDialog.getDirectory() + importDialog.getFile();
        try{
            BufferedReader br = new BufferedReader(new FileReader(importFilename));
            PrintWriter pw = new PrintWriter(settingsFilename);
            String line="";
            while ((line=br.readLine())!=null) {
                pw.println(line);
                pw.flush();
            }
            br.close();
            pw.close();
        } catch(IOException ex){
            ex.printStackTrace();
        }
        loadSettings(settings);
    }

    private void exportSettings(Properties settings) {
        saveSettings(settings);
        FileDialog exportDialog = new FileDialog(this, "Export settings...", FileDialog.SAVE);
        exportDialog.setFile(settingsFilename);
        exportDialog.setFilenameFilter(new FilenameFilter() {
            public boolean accept(File dir, String name) {
                return name.endsWith(settingsFileExtension);
            }
        });
        exportDialog.setVisible(true);
        String exportFilename = exportDialog.getDirectory() + exportDialog.getFile();
        try {
            settings.store(new FileOutputStream(exportFilename), null);
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        } catch (IOException ex2) {
            ex2.printStackTrace();
        }
    }

    public Properties getSettings() {
        return settings;
    }

    private String settingsFileExtension;
    private String settingsFilename;
    /** Creates new form SettingsFrame */
    public SettingsManager(String settingsFileExtensionArg, String settingsFilenameArg) {
        initComponents();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

        settingsFileExtension = settingsFileExtensionArg;
        settingsFilename = settingsFilenameArg;

        //load the settings file
        settings = new Properties();
        loadSettings(settings);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel3 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        warnPosturePopup = new javax.swing.JCheckBox();
        warnPostureSound = new javax.swing.JCheckBox();
        warnPostureRestriction = new javax.swing.JCheckBox();
        jLabel3 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        warnWorkPopup = new javax.swing.JCheckBox();
        warnWorkSound = new javax.swing.JCheckBox();
        warnWorkRestriction = new javax.swing.JCheckBox();
        warnBreakPopup = new javax.swing.JCheckBox();
        warnBreakSound = new javax.swing.JCheckBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        warnWorkInterval = new javax.swing.JSpinner();
        warnBreakInterval = new javax.swing.JSpinner();
        jButton4 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Settings");

        jButton1.setText("Ok");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Cancel");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton5.setText("Help");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(182, Short.MAX_VALUE)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton5)
                .addGap(1, 1, 1))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButton1)
                .addComponent(jButton2)
                .addComponent(jButton5))
        );

        jPanel1.setBorder(null);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Warnings"));

        warnPosturePopup.setText("with a warning message in a pop-up window");

        warnPostureSound.setText("with sound");

        warnPostureRestriction.setText("by restricting computer usage");

        jLabel3.setText("Warn me if my posture deteriorates");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(51, 51, 51)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(warnPostureSound)
                            .addComponent(warnPosturePopup)
                            .addComponent(warnPostureRestriction)))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel3)))
                .addContainerGap(91, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(warnPosturePopup)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(warnPostureSound)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(warnPostureRestriction)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Other"));

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 440, Short.MAX_VALUE)
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Posture Correction", jPanel1);

        jPanel2.setBorder(null);

        warnWorkPopup.setText("with a warning message in a pop-up window");

        warnWorkSound.setText("with sound");

        warnWorkRestriction.setText("by restricting computer usage");

        warnBreakPopup.setText("with a warning message in a pop-up window");

        warnBreakSound.setText("with sound");

        jLabel1.setText("minutes");

        jLabel2.setText("minutes");

        jLabel4.setText("Warn me to take breaks every");

        jLabel5.setText("Warn me to go back to work if my break exceeds");

        warnWorkInterval.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(30.0d), Double.valueOf(0.1d), null, Double.valueOf(1.0d)));
        warnWorkInterval.setValue(60);

        warnBreakInterval.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(5.0d), Double.valueOf(0.5d), null, Double.valueOf(1.0d)));
        warnBreakInterval.setValue(15);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(warnWorkInterval, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel1))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(41, 41, 41)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(warnWorkSound)
                            .addComponent(warnWorkPopup)
                            .addComponent(warnWorkRestriction)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(warnBreakInterval, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel2))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(41, 41, 41)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(warnBreakSound)
                            .addComponent(warnBreakPopup))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel4)
                    .addComponent(warnWorkInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(warnWorkPopup)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(warnWorkSound)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(warnWorkRestriction)
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel5)
                    .addComponent(warnBreakInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(warnBreakPopup)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(warnBreakSound)
                .addContainerGap(67, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Breaks", jPanel2);

        jButton4.setText("Export");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton3.setText("Import");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 456, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 311, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jButton4)
                        .addComponent(jButton3)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        saveSettings(settings);
        dispose();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        exportSettings(settings);
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        importSettings();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        dispose();
    }//GEN-LAST:event_jButton2ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JSpinner warnBreakInterval;
    private javax.swing.JCheckBox warnBreakPopup;
    private javax.swing.JCheckBox warnBreakSound;
    private javax.swing.JCheckBox warnPosturePopup;
    private javax.swing.JCheckBox warnPostureRestriction;
    private javax.swing.JCheckBox warnPostureSound;
    private javax.swing.JSpinner warnWorkInterval;
    private javax.swing.JCheckBox warnWorkPopup;
    private javax.swing.JCheckBox warnWorkRestriction;
    private javax.swing.JCheckBox warnWorkSound;
    // End of variables declaration//GEN-END:variables

}
